home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 2.0 / PInterfaces / CursorCtl.p < prev    next >
Encoding:
Text File  |  1995-04-18  |  5.1 KB  |  128 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        CursorCtl.p
  3.  
  4.     Copyright:    © 1983-1993 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Version:    System 7.1 for ETO #11
  8.     Created:    Tuesday, March 30, 1993 18:00
  9.  
  10. }
  11.  
  12. {$IFC UNDEFINED UsingIncludes}
  13. {$SETC UsingIncludes := 0}
  14. {$ENDC}
  15.  
  16. {$IFC NOT UsingIncludes}
  17.     UNIT CursorCtl;
  18.     INTERFACE
  19. {$ENDC}
  20.  
  21. {$IFC UNDEFINED UsingCursorCtl}
  22. {$SETC UsingCursorCtl := 1}
  23.  
  24.  
  25. TYPE
  26.  
  27. { Kinds of cursor supported by CursorCtl }
  28. Cursors = (HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,
  29.     ARROW_CURSOR);
  30.  
  31. acurPtr = ^Acur;
  32. acurHandle = ^acurPtr;
  33. Acur = RECORD
  34.     n: INTEGER;         {Number of cursors ("frames of film")}
  35.     index: INTEGER;     { Next frame to show <for internal use>}
  36.     frame1: INTEGER;    {'CURS' resource id for frame #1}
  37.     fill1: INTEGER;     {<for internal use>}
  38.     frame2: INTEGER;    {'CURS' resource id for frame #2}
  39.     fill2: INTEGER;     {<for internal use>}
  40.     frameN: INTEGER;    {'CURS' resource id for frame #N}
  41.     fillN: INTEGER;     {<for internal use>}
  42.     END;
  43.  
  44.  
  45.  
  46. PROCEDURE InitCursorCtl(newCursors: UNIV acurHandle);
  47. { Initialize the CursorCtl unit. This should be called once prior to calling
  48. RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or
  49. Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the
  50. 'acur' resource and the 'CURS' resources specified by the 'acur' resource
  51. ids.  If any of the resources cannot be loaded, the cursor will not be
  52. changed.
  53.  
  54. The 'acur' resource is assumed to either be in the currently running tool or
  55. application, or the MPW Shell for a tool, or in the System file.  The 'acur'
  56. resource id must be 0 for a tool or application, 1 for the Shell, and 2 for
  57. the System file.
  58.  
  59. If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted
  60. resource designated by the caller and it will be used instead of doing a
  61. GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without
  62. calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for
  63. the user the first time it is called.  However, the possible disadvantage of
  64. using this technique is that the resource memory allocated may have
  65. undesirable affect (fragmentation?) on the application. Using InitCursorCtl
  66. has the advantage of causing the allocation at a specific time determined by
  67. the user.
  68.  
  69. Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.    Specifically,
  70. it changes each FrameN/fillN integer pair to a handle to the corresponding
  71. 'CURS' resource also in memory.  Thus if NewCursors is not NULL when
  72. InitCursorCtl is called, the caller must guarantee NewCursors always points to
  73. a "fresh" copy of an 'acur' resource.  This need only be of concern to a
  74. caller who wants to repeatly use multiple 'acur' resources during execution of
  75. their programs.
  76.  }
  77.  
  78. PROCEDURE RotateCursor(counter: LONGINT);
  79. { RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to
  80. animate whatever sequence of cursors set up by InitCursorCtl. The next cursor
  81. ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing
  82. or decrementing index maintained by the caller). A positive counter sequences
  83. forward through the cursors (e.g., it rotates the "beach ball" cursor
  84. clockwise), and a negative cursor sequences through the cursors backwards
  85. (e.g., it rotates the "beach ball" cursor counterclockwise).  Note,
  86. RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  87.   It is assumed the cursor is visible from a prior Show_Cursor call.
  88.  }
  89.  
  90. PROCEDURE SpinCursor(increment: INTEGER);
  91. { SpinCursor is similar in function to RotateCursor, except that instead of
  92. passing a counter, an Increment is passed an added to a counter maintained
  93. here.  SpinCursor is provided for those users who do not happen to have a
  94. convenient counter handy but still want to use the spinning "beach ball"
  95. cursor, or any sequence of cursors set up by InitCursorCtl.  A positive 
  96. increment sequences forward through the curos (rotating the "beach ball"
  97. cursor clockwise), and a negative increment sequences backward through the
  98. cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value
  99. for the increment resets the counter to zero.  Note, it is the increment, and
  100. not the value of the counter that determines the sequencing direction of the
  101. cursor (and hence the spin direction of the "beach ball" cursor).
  102.  }
  103.  
  104. PROCEDURE Hide_Cursor;
  105. { Hide the cursor if it is showing.This is this unit's call to the Mac
  106. HideCursor routine.Thus the Mac cursor level is decremented by one when this
  107. routine is called.
  108.  }
  109.  
  110. PROCEDURE Show_Cursor(cursorKind: Cursors);
  111. { Increment the cursor level, which may have been decremented by Hide_Cursor,
  112. and display the specified cursor if the level becomes 0 (it is never
  113. incremented beyond 0).The CursorKind is the kind of cursor to show.  It is
  114. one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR,
  115. WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is
  116. done for the specified cursor prior to doing a ShowCursor.    HIDDEN_CURSOR just
  117. causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if
  118. there is already a grafPort set up pointed to by 0(A5).
  119.  }
  120.  
  121.  
  122. {$ENDC}    { UsingCursorCtl }
  123.  
  124. {$IFC NOT UsingIncludes}
  125.     END.
  126. {$ENDC}
  127.  
  128.